<template>
  <div class="container">
    <div class="header">
      <search :search=search></search>
      <swiper  class="banner">
        <block v-for="item in imgUrls" :key="item">
          <swiper-item :style="{width:winWidth+'px'}">
            <image :src="item" class="slide-image" :style="{width:winWidth+'px'}" height="150" />
          </swiper-item>
        </block>
      </swiper>
    </div>
    <div class="homeClass">
      <ul>
        <li v-for="item in classList" :key="item">
          <a>
            <img :src="item.url" alt="">
            <span>{{item.name}}</span>
          </a>
        </li>
      </ul>
    </div>

  <tjmodel></tjmodel>
<bannerone></bannerone>
<workList></workList>
  </div>
</template>

<script>
  import card from '@/components/card'
  import search from '@/components/search'
  import tjmodel from '@/components/tjmodel'
  import bannerone from '@/components/bannerone'
  import workList from '@/components/workList'

  export default {
    data() {
      return {
        search: 'Hello World',
        userInfo: {},
        winWidth:"",
        imgUrls: [
          'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
          'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
          'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
        ],
        classList:[
          {name:'分类',url:'/static/image/vip.jpg'},
           {name:'男装',url:'/static/image/vip.jpg'},
            {name:'家电',url:'/static/image/vip.jpg'},
             {name:'3C',url:'/static/image/vip.jpg'},
              {name:'积分兑换',url:'/static/image/vip.jpg'}
        ]
      }
    },
    components: {
      card,
      search,
      tjmodel,
      bannerone,
      workList
    },
    methods: {
      bindViewTap() {
        const url = '../logs/main'
        wx.navigateTo({
          url
        })
      },
      getUserInfo() {
        // 调用登录接口
        wx.login({
          success: () => {
            wx.getUserInfo({
              success: (res) => {
                this.userInfo = res.userInfo
              }
            })
          }
        })
      }
    },
    created() {
      // 调用应用实例的方法获取全局数据
      this.getUserInfo()
         wx.getStorageSync('userSystem')
      this.winWidth = wx.getStorageSync('userSystem').windowWidth
      wx.login({
        success: () => {
          wx.getUserInfo({
            success: (res) => {
              this.userInfo = res.userInfo
              console.log(res)
            }
          })
        }
      })

    }
  }
</script>

<style scoped>

</style>
